package com.bigknow.appstore.web.console.service;

import com.bigknow.appstore.web.console.app.Application;
import com.bigknow.appstore.web.console.app.ApplicationState;
import org.mongodb.morphia.Datastore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 李科风 on 2016-10-25.
 */
@Service
public class ApplicationManagerService {

    @Autowired
    private Datastore ds;

    public int getTotalAppCount() {
        return (int) ds.find(Application.class).countAll();
    }

    public int getAppCountByState(ApplicationState state) {
        return (int) ds.find(Application.class, "state", state).countAll();
    }
}
